package com.itboye.textileexpres.shopcart;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

import android.view.View;
import android.view.ViewGroup;

import com.allen.expandablelistview.BaseSwipeMenuExpandableListAdapter;
import com.allen.expandablelistview.SwipeMenuExpandableListView;
import com.baoyz.swipemenulistview.ContentViewWrapper;
import com.itboye.textileexpes.beans.ShopCartModel;
import com.itboye.textileexpes.presenter.ShopCartPresenter;
import com.itboye.textileexpres.R;
import com.itboye.textileexpres.base.BaseFragment;
import com.itboye.textileexpres.base.ResultEntity;
import com.itboye.textileexpres.base.SpPublicParams;
import com.itboye.textileexpres.shopcart.ShopcartExpandableListViewAdapter.CheckInterface;
import com.itboye.textileexpres.shopcart.ShopcartExpandableListViewAdapter.ModifyCountInterface;
import com.itboye.textileexpres.util.SPUtils;

public class shopcart extends BaseFragment implements Observer {
	AppAdapter adapter;
	ShopCartModel cartModel = new ShopCartModel();
	ShopCartPresenter presenter;
	private List<ShopCartModel> goodsList = new ArrayList<ShopCartModel>();
	private String uid;
	SwipeMenuExpandableListView exListView;

	@Override
	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.fragment_shopcar;
	}

	@Override
	public void onMyActivityCreated() {
		// TODO Auto-generated method stub
		presenter = new ShopCartPresenter(this);
		uid = (String) SPUtils.get(getActivity(), null, SpPublicParams.UID, "");
		cartModel.setUid(uid);
		presenter.getInfo(cartModel);
	}

	@Override
	public void update(Observable observable, Object data) {
		// TODO Auto-generated method stub
		ResultEntity entity = handlerError(data);
		if (entity != null) {
			if (entity.getEventType() == ShopCartPresenter.QueryShopCartSuccessEvent) {
				goodsList.addAll((List<ShopCartModel>) entity.getData());
				toast("1,");
			} else if (entity.getEventType() == ShopCartPresenter.QueryShopCartFailureEvent) {
				toast("哈,");

			} else if (entity.getEventType() == ShopCartPresenter.DeleteShopCartSuccessEvent) {

			} else if (entity.getEventType() == ShopCartPresenter.DeleteShopCartFailureEvent) {

			} else if (entity.getEventType() == ShopCartPresenter.UpdateShopCartSuccessEvent) {

			} else if (entity.getEventType() == ShopCartPresenter.UpdateShopCartFailureEvent) {

			}
		}
	}

	class AppAdapter extends BaseSwipeMenuExpandableListAdapter {
		CheckInterface checkInterface;
		ModifyCountInterface modifyCountInterface;
		ViewHolder holder = null;

		public void setCheckInterface(CheckInterface checkInterface) {
			this.checkInterface = checkInterface;
		}

		public void setModifyCountInterface(
				ModifyCountInterface modifyCountInterface) {
			this.modifyCountInterface = modifyCountInterface;
		}

		@Override
		public Object getChild(int groupPosition, int childPosition) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getChildId(int groupPosition, int childPosition) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public int getChildrenCount(int groupPosition) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public Object getGroup(int groupPosition) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public int getGroupCount() {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public long getGroupId(int groupPosition) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public boolean hasStableIds() {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean isChildSelectable(int groupPosition, int childPosition) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean isGroupSwipable(int groupPosition) {
			// TODO Auto-generated method stub

			return true;
		}

		@Override
		public boolean isChildSwipable(int groupPosition, int childPosition) {
			// TODO Auto-generated method stub
			return true;
		}

		@Override
		public ContentViewWrapper getGroupViewAndReUsable(int groupPosition,
				boolean isExpanded, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public ContentViewWrapper getChildViewAndReUsable(int groupPosition,
				int childPosition, boolean isLastChild, View convertView,
				ViewGroup parent) {
			// TODO Auto-generated method stub
			return null;
		}

	}

	class ViewHolder {

	}
}
